<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>A36信息</title>

    <link rel="stylesheet" th:href="@{/static/iview/iview.css}">
    <script th:src="@{/static/libs/jquery-3.2.1.min.js}" type="text/javascript"></script>
	<script th:src="@{/static/libs/vue.min.js}" type="text/javascript"></script>
	<script th:src="@{/static/layer/layer.js}" type="text/javascript"></script>
   <script th:src="@{/static/iview/iview.min.js}" type="text/javascript"></script>
	<script th:src="@{/static/common.js}" type="text/javascript"></script>
    <style type="text/css">
	[v-cloak] {
			  display: none;
			}
	</style>
</head>
<body>
<div id="app" v-cloak>
        <div style="margin-bottom: 6px;margin: 30px">
			<i-input v-model="content" placeholder="外部标识、名称、hex"  style="width: 300px"></i-input>
	
		    <i-select  v-model="organtype"  style="width: 170px" @on-change="changorgantypelist">
		              <i-option v-for="item in organtypelist"  :value="item.id"  :key="item.value">{{item.value}} </i-option>
		     </i-select>
			<i-button type="primary" @click="search()" icon="ios-search">搜索</i-button>
			<i-button type="primary" @click="empty()" icon="ios-close-empty">清空</i-button>
		</div>
		<div style="margin-bottom: 6px;margin: 30px">
			<template> 
				<i-table border :content="self" :columns="tableTitle" :data="datalist"></i-table>
			 	<br>
<!-- 			 	<Page :total="dataCount" :page-size="pageSize" show-total @on-change="changepage" @on-page-size-change="changePageSize"></Page> -->
			 	<!--分页功能-->
				<Page :current="1" :total="dataCount" :page-size="pageSize"  @on-change="changepage"  show-elevator show-sizer show-total></Page>
				 
			</template>
		</div>
</div>
<script type="text/javascript">
var vm = new Vue({
	el : '#app',
	data : {
		content : '',
		pageNo : 0,
		pageSize : 10,// 每页显示多少条
		dataCount:"", // 总数据的条目
		datalist: [], //接口获取的总数据
		historyData:'',//展示的数据 
		organtype:'',
		organtypelist: [
			{"id":"","value":" 选择"},
			{"id":"1","value":"1 - 高速公路"},
			{"id":"2","value":"2 - 收费站"},
			{"id":"5","value":"5 - 业主"},
			{"id":"8","value":"8 - 路段"},
			{"id":"12","value":"12 - 广场"},
			{"id":"13","value":"13 - 车道(外省有,北京无)"},
			{"id":"14","value":"14 - 收费单元 - 门架"}
		],
		tableTitle:[ 
		{
		   title : "编号",
		   type: 'index',
		   align: 'center',
            width: 70
		 },
		{
			key : "organId",
			title : "内部标识",
			/* width : 120 */
		},
		{
			key : "organCharacter",
			title : "类型",
			width : 180,
			render : function(h, params) {
				var text = params.row.organCharacter+" - 未定义类型";
				if(params.row.organCharacter == 1){
					text ="1 - 高速公路";
				}else	 if(params.row.organCharacter == 2){
					text ="2 - 收费站";
				}else	 if(params.row.organCharacter == 5){
					text ="5 - 业主 ";
				}else	 if(params.row.organCharacter == 8){
					text ="8 - 路段";
				}else	 if(params.row.organCharacter == 12){
					text ="12 - 广场";
				}else	 if(params.row.organCharacter == 13){
					text ="13 - 车道(外省有，北京无)";
				}else	 if(params.row.organCharacter == 14){
					text ="14 - 收费单元 - 门架";
				}
				  return h('div',text);
			}
		},
		{
			key : "tollorganid",
			title : "外部标识",
			render : function(h, params) {
				var text = '';
				if(params.row.tollorganid !=''){
					text = params.row.tollorganid + ' ('+params.row.tollorganid.length+'位) '
				}
				return h('div',text);
			}
		},
		{
			key : "tollOrganName",
			title : "外部名称"
		}, 
		{
			key : "organHex",
			title : "HEX值",
			 width : 120
		}, 
	  {
			key : "higherStationId",
			title : "上级收费站外部编号"
		}, 
		{
			key : "higherRoadId",
			title : "上级路段外部编号"
		}, 
		{
			key : "status",
			title : "状态",
			width : 80,
			render : function(h, params) {
				var text = params.row.status+" - 未知状态";
				if(params.row.status == 0){
					text = "启用";
				}else if(params.row.status == 1){
					text = "禁用";
				}
				  return h('div',text);
			}
		}, 
		{
			key : "createTime",
			title : "创建时间",
			width : 150,
			render : function(h, params) {
				  return h('div',
						  formatDate(new Date(params.row.createTime),'yyyy-MM-dd hh:mm:ss'));
			}
		}/*, {
			title : '操作',
			key : 'action',
			width : 90,
			align : 'left',
			render : function(h, params) {
				var functionList = [];
				//修改
				var edit = h('Button', {
					props : {
						type : 'primary',
						size : 'small',
						icon : 'edit'
					},
					style : {
						marginRight : '8px'
					},
					on : {
						click : function() {
							vm.edit(params.row);
						}
					}
				}, '修改');
				functionList.push(edit);
		
				// 返回方法集合
				return h('div', functionList);
			}
		}*/ ]	
	},
	methods : {
		//搜索
		search : function(){
			this.loadlist(1);
		},
		empty : function(){
			vm.content = '';
			vm.organtype='';
			this.loadlist(1);
		},
		//任务列表(自行实现分页)
		loadlist : function(index) {
			let self=this;   //申明个this对象
			
			var page = {};
			page['pageIndex']= index ;
			page['pageSize']= this.pageSize;
					
			var params = {};
			var contentValue = this.content.trim();
			if(this.organtype!=''){
				params['organCharacter'] =parseInt(this.organtype);
			}
			if(this.content !=''){
				if(!isNaN(this.content)){
					params['organId'] = parseInt(contentValue);
				}
			    params['tollorganid'] = contentValue;
				params['tollOrganName'] = contentValue;
				params['organHex'] =contentValue;
				params['higherStationId'] = contentValue;
				params['higherRoadId'] = contentValue;
			}
			 var conditional = {};
			 conditional['page'] = page;
			 conditional['params'] = params;
			 var json =  JSON.stringify(conditional);
			
			$.ajax({
				url:"../monitor/getA36List",
				type:"post",
				dataType: "json",
				contentType: 'application/json', 
				data: json,
				success: function(data) {
					vm.datalist = data.result.rows;
					vm.dataCount = data.result.total; //接口返回数据的总条目数
					if(vm.dataCount < vm.pageSize){   
                        vm.historyData   = vm.JobData
                    }else{
                        vm.historyData = vm.datalist.slice(0,self.pageSize);
                    }
				}
			});
		},
		 //页数变化的时候改变每一页的内容
        changepage(index){
			this.loadlist(index);
        },
        changorgantypelist:function(value){
     	   vm.organtype=value;
        },
		edit : function(quartz){
			dialogOpen({
				title: '修改',
				url: 'task/add.shtml',
				//屏幕小 滚动条显示
				scroll : true,
				width: '450px',
				height: '450px',
				success : function(iframeId){
					top.frames[iframeId].vm.formQuartz = quartz;
				},
				yes : function(iframeId) {
					top.frames[iframeId].vm.acceptClick();
				},
			});
		},
		//移除任务
		remove : function(jobName,jobGroup){
			var that = this;
			top.layer.confirm('确定要移除任务吗？', {btn: ['确定','取消']}, function(){
				$.ajax({
					url:"../job/remove",
					type:"post",
					data:{'time':(new Date()).toString(),"jobName":jobName,'jobGroup':jobGroup},
					success: function(result) {
						if(result.code=="0"){
							top.layer.msg('任务移除成功', {icon: 1});
							window.setTimeout(that.loadlist(),1500); 
						}
					}
				});
			});
		}
	},
	created : function() {
		 this.loadlist();
         this.changepage(0);
	}
})

</script>
</body>
</html>